package com.wlyuan.open.scanner.domain.order;

import com.wlyuan.open.scanner.dao.entity.OrderAdditionTransportDO;
import com.wlyuan.open.scanner.utils.mappings.MappingInvalid;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @author lijing
 * @description
 */
public class OrderTransportConvert {

    private static final Convert CONVERT = Mappers.getMapper(Convert.class);

    @Mapper(uses = MappingInvalid.class)
    public interface Convert {

        @Mappings({
                @Mapping(target = "type", source = "transportType"),
                @Mapping(target = "orderId", source = "transportOrderid"),
                @Mapping(target = "no", source = "transportNo"),
                @Mapping(target = "startTime", source = "transportStarttime"),
                @Mapping(target = "endTime", source = "transportEndtime"),
                @Mapping(target = "startPlace", source = "transportStartplace"),
                @Mapping(target = "endPlace", source = "tranposrtEndplace"),
                @Mapping(target = "remark", source = "transportRemark"),
                @Mapping(target = "arrive", source = "transportIsarrive"),
                @Mapping(target = "speed", source = "transportSpeed"),
                @Mapping(target = "wayProvinceCode", source = "transportWayprovince"),
                @Mapping(target = "wayCityCode", source = "transportWaycity"),
                @Mapping(target = "wayDistrictCode", source = "transportWaydistrict"),
                @Mapping(target = "wayTo", source = "transportWayto"),
                @Mapping(target = "sequence", source = "transportSequence"),
                @Mapping(target = "invalid", source = "transportInvalid"),
                @Mapping(target = "id", source = "transportId"),
                @Mapping(target = "operator", source = "transportOperator"),
                @Mapping(target = "operatorTime", source = "transportOperatortime"),
        })
        OrderTransport convert(OrderAdditionTransportDO source);

        List<OrderTransport> convert(List<OrderAdditionTransportDO> list);

    }

    public static List<OrderTransport> convert(List<OrderAdditionTransportDO> creation) {
        return CONVERT.convert(creation);
    }

    public static OrderTransport convert(OrderAdditionTransportDO source) {
        return CONVERT.convert(source);
    }
}
